package demo1229.homework;


import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Demo4 {
    public static void main(String[] args) {

         new Thread(new Runnable() {
            @Override
            public void run(){
                SimpleDateFormat sdp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                Calendar cal = Calendar.getInstance();
                while (true) {
                    try {
                        System.out.println(sdp.format(cal.getTime()));
                        cal.add(Calendar.SECOND,1);
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        },"时间:").start();




    }
}



